package com.qbccn.bbs.service.impl;

import com.qbccn.bbs.config.ValueConfig;
import com.qbccn.bbs.domain.BbsArticleClass;
import com.qbccn.bbs.mapper.BbsArticleClassMapper;
import com.qbccn.bbs.service.PageService;
import com.qbccn.bbs.service.RedisService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author linke
 * @date 2020/8/1 0:00
 * @description
 */
@Service
public class PageServiceImpl implements PageService {

  @Autowired
  private RedisService redisService;
  @Autowired
  private BbsArticleClassMapper bbsArticleClassMapper;

  @Override
  public List<BbsArticleClass> getArticleClass() {
    Object c=redisService.get("aclass");
    if (c!=null){
      return (List<BbsArticleClass>)c;
    }
    List<BbsArticleClass> bbsArticleClasses=bbsArticleClassMapper.get();
    redisService.set("aclass",bbsArticleClasses, ValueConfig.redisArticleClassTime);
    return bbsArticleClasses;
  }
}
